package com.dc.controller;

import com.dc.common.ResponseResultVO;
import com.dc.ro.EsDeviceRO;
import com.dc.service.EsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "Es管理")
@RestController
@RequestMapping("/statisticalQuery")
public class EsController {

    @Resource
    EsService esService;

    @ApiOperation(value = "创建索引", notes = "创建索引")
    @GetMapping("/addIndex")
    public ResponseResultVO addIndex(String index) {
        return esService.addIndex(index);
    }

    @ApiOperation(value = "删除索引", notes = "删除索引")
    @GetMapping("/deleteIndex")
    public ResponseResultVO deleteIndex(String index) {
        return esService.deleteIndex(index);
    }

    @ApiOperation(value = "新增数据", notes = "创建索引")
    @GetMapping("/addIndexData")
    public ResponseResultVO addIndexData(String index) {
        return esService.addIndexData(index);
    }

    @ApiOperation(value = "条件/分页查询", notes = "条件/分页查询")
    @PostMapping("/conditionQueryIndexData")
    public ResponseResultVO conditionQueryIndexData(@RequestBody EsDeviceRO ro) {
        return esService.conditionQueryIndexData(ro);
    }

    @ApiOperation(value = "根据条件删除", notes = "根据条件删除")
    @PostMapping("/deleteIndexData")
    public ResponseResultVO deleteIndexData(@RequestBody EsDeviceRO ro) {
        return esService.deleteIndexData(ro);
    }
}
